package com.mega.fe.common;

import com.mega.fe.render.RendererUtils;
import com.mega.fe.render.ShaderGetter;
import com.mega.fe.render.shaders.ShaderInit;
import net.minecraft.client.Minecraft;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class ModifyShader {
    public static float time_the_world = 0F;

    public static void setup() {
        if (Minecraft.getInstance().gameRenderer == null)
            return;
        if (ShaderGetter.nameEquals("post/the_world.json")) {
            time_the_world += 0.001F;
        } else time_the_world = 0f;
        if (ShaderInit.RAIN != null) {
            RendererUtils.time+=0.001F;
            //System.out.println(RendererUtils.time);
        }
    }

    @SubscribeEvent
    public static void rendering(TickEvent.RenderTickEvent event) {
        if (ShaderGetter.gameRenderer != null && ShaderGetter.currentEffect() != null)
            ShaderGetter.updateUniform_post("time", time_the_world);
    }
}
